<template>
    <div class="my-address">
       <div class="my-adress-info" v-for="item in addressArr" :key="item.id">
           <div>
                <label class="person-name">{{item.name}}</label>
                <label class="person-phone">{{item.telephone}}</label>
           </div>
           <img src="../../../assets/img/me/default.png" class="default-address" v-if="item.isDefault">
           <p class="person-adress">{{item.city}} {{item.detailAddress}}</p>
           <router-link tag="div" class="editor-adress" :to="'/edit_address/' + item.id">编辑</router-link>
       </div>
       <div class="add-address" @click="addAddress">新建收货地址</div>
    </div>
</template>
<script>
import { post } from '../../../../util/http.js'
import { Toast } from 'mint-ui'
export default {
    data() {
        return {
            addressArr: []
        }
    },
    mounted() {
        this.$nextTick(() => {
            let info = JSON.parse(window.localStorage.getItem('dongHang_data'))
            post('http://dlsapi.rz158.com/address/selectAddress', {
                agentId: info.agentId
            }).then(res => {
                if(res.code != 0) {
                    Toast({
                        message: res.message,
                        duration: 1000
                    })
                } else {
                    this.addressArr = res.t
                }
            })
        })
    },
    methods: {
        addAddress() {
            this.$router.push('/add_address')
        }
    }
}
</script>

<style lang="less" scoped>
.my-address{
    padding-left: .3rem;
}
.my-adress-info{
    position: relative;
    padding: .3rem .3rem .3rem 0rem;
    height: 1.12rem;
    border-bottom:1px solid #cccccc;
    font-size: .3rem;
    font-weight: 600;
    .person-adress{
        display: inline-block;
        font-weight: 400;
        padding-top: .18rem;
        max-width: 5rem;
        font-size: .28rem;
    }
    .editor-adress{
        // width: .72rem;
        height: .34rem;
        display: inline-block;
        font-weight: 400;
        position: absolute;
        right: 0px;
        padding-left: .2rem;
        padding-right: .3rem;
        border-left: 1px solid #cccccc;
        line-height: 0.34rem;
        color: #707070;
    }
    .default-address{
        position: relative;
        // top: -.24rem;
        width: .5rem;
        height: .3rem;
        display: inline-block;
    }
}
.add-address{
    position: absolute;
    font-size: .32rem;
    color: #ffffff;
    background: #29abae;
    height: .82rem;
    width: 100%;
    z-index: 99;
    bottom: 0rem;
    margin-left: -.3rem;
    text-align: center;
    line-height: .82rem;
}
</style>

